package cn.lzd.mr;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.net.URI;

/**
 * Created by lzd on 2018/6/1.
 */
public class PathUtil {

    public static String getpath(String filename) {
        return PathUtil.class.getResource("/").getPath() + filename + "/";
    }

    public static void handleOutPath(String outpath, Configuration conf) {
        try {
            FileSystem fileSystem = FileSystem.get(new URI(outpath), conf);
            if (fileSystem.exists(new Path(outpath))) {
                fileSystem.delete(new Path(outpath), true);
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }
}
